/*
 * @lc app=leetcode.cn id=929 lang=cpp
 *
 * [929] 独特的电子邮件地址
 */

// @lc code=start
class Solution {
public:
    int numUniqueEmails(vector<string>& emails) {
        set<string> s;
        for(auto email : emails){
            int i = email.find('@');
            string local = email.substr(0, i);
            string domain = email.substr(i);
            local.erase(remove(local.begin(), local.end(), '.'), local.end());
            if(local.find('+') != string::npos){
                local = local.substr(0, local.find('+'));
            }
            s.insert(local + domain);
        }
        return s.size();
    }
};
// @lc code=end

